<?php 
class ModuleWelcome extends Controller {
	function fetch() {
		$config		=& $this->locator->get('config');
		$customer	=& $this->locator->get('customer');
		$language	=& $this->locator->get('language');
		$url		=& $this->locator->get('url');
		$template   =& $this->locator->get('template');

		if (!$config->get('welcome_status')) { return; }

		$language->load('extension/module/welcome.php');

		$view = $this->locator->create('template');

		$view->set('tpl', $template);

		$view->set('heading_title', $language->get('heading_title', $config->get('config_store')));

		if ($customer->isLogged()) {
			$welcome = $config->has('welcome_text_logged')?$config->get('welcome_text_logged', $customer->getFirstName()):NULL;
			if (!$welcome) { $welcome = $language->get('text_logged', $customer->getFirstName()); }
		} else {
			$welcome = $config->has('welcome_text_greeting')?$config->get('welcome_text_greeting', $url->ssl('account_login'), $url->ssl('account_create')):NULL;
			if (!$welcome) { $welcome = $language->get('text_greeting', $url->ssl('account_login'), $url->ssl('account_create')); }
		}
		$view->set('text_welcome', $welcome);

		return $view->fetch('module/welcome.tpl');
	}
}
?>
